# -*- coding: utf-8 -*-
# @Time    : 2021/4/15 0015 16:23
# @Author  : 蒋才果
# @Email   : 1476235300@qq.com
# @File    : func.py
# @Software: PyCharm
import string
def check_num(passwd):
    #判断密码有无数字
    for i in passwd:
        if i.isdigit():
            return True
    return False

def check_low(passwd):
    #判断密码中有无小写字母
    for i in passwd:
        if i in string.ascii_lowercase:
            return True
    return False

def check_upp(passwd):
    #判断密码中有无大写字母
    for i in passwd:
        if i in string.ascii_uppercase:
            return True
    return False

def check_pun(passwd):
    #判断密码中有无特殊字符
    for i in passwd:
        if i in string.punctuation:
            return True
    return False

def check_rep(passwd):
    k = 0;i = 0;j = 3
    while j <= len(passwd):
        f = passwd[i:j]
        x = i + 3
        y = j + 3
        i += 1
        j += 1
        while y <= len(passwd):
            g = passwd[x:y]
            if f == g:
                k += 1
            x += 1
            y += 1
    if k > 0:
        return False
    else:
        return True

def main():
    pwd = input("输入密码：")
    garde = 2
    #判断长度大于8
    if len(pwd) > 8:
        garde += 1
    else:
        print("密码长度小于8位")
    #判断至少含有三种类型组成
    if check_num(pwd) and check_pun(pwd) and check_upp(pwd):
        garde += 1
    elif check_num(pwd) and check_low(pwd) and check_upp(pwd):
        garde += 1
    elif check_num(pwd) and check_low(pwd) and check_pun(pwd):
        garde += 1
    elif check_upp(pwd) and check_low(pwd) and check_pun(pwd):
        garde += 1
    else:
        print("密码种类少于三种")
    #判断有无超多或等于3的字串重复
    if check_rep(pwd):
        garde += 1
    else:
        print("有重复大于等于3的子串")
    print("密码评分:",garde)
main()



